import radColor from '../util/radColor'
import { getRandom } from '../util/radColor'
const divContainer = document.getElementById('divContainer')
const divCenter = document.getElementById('divCenter')

export default function (n, isPrime) {
  const span = document.createElement('span')
  let color = ''
  if (isPrime) {
    color = radColor()
    span.style.color = color
  }
  span.innerText = n
  divContainer.appendChild(span)

  divCenter.innerText = n

  if (isPrime) {
    const div = document.createElement('div')
    div.className = 'center'
    div.style.color = color
    div.innerText = n
    document.body.appendChild(div)

    // 只要读取某个元素的位置或者尺寸信息，则会导致浏览器重新渲染
    getComputedStyle(div).height
     div.style.transform = `translate(${getRandom(-100, 200)}px,${getRandom(
      -100,
      200
    )}px)`
    div.style.opacity = 0
  }
}
